﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using SES.CMS.DO;
using SES.CMS.BL;
using SES.CMS.AdminCP;

namespace SES.CMS
{
    public partial class HoiDap : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            rptHoiDap.DataSource = new cmsHoiDapBL().ViewOnWebsite();
            rptHoiDap.DataBind();
        }

        protected void ButtonSend_Click(object sender, EventArgs e)
        {
            ccJoin.ValidateCaptcha(txtbv.Text);
            if (!ccJoin.UserValidated)
            {
                Response.Write("<script language='javascript'>alert('Mã bảo vệ chưa chính xác..!!..')</script>");
                return;
            }
            else
            {
                try
                {
                    cmsHoiDapDO HoiDapDO = new cmsHoiDapDO();
                    cmsHoiDapBL HoiDapBL = new cmsHoiDapBL();

                    HoiDapDO.HoTenNguoiHoi = txtTen.Text;
                    HoiDapDO.Email = txtEmail.Text;
                    HoiDapDO.CauHoi = txtND.Text;
                    HoiDapDO.NgayHoi = DateTime.Now;
                    HoiDapDO.NgayTraLoi = DateTime.Now;
                    HoiDapDO.DaTraLoi = false;
                    HoiDapDO.HienThi = false;

                    HoiDapBL.Insert(HoiDapDO);
                    Functions.Alert("Gửi câu hỏi thành công!", Request.Url.ToString());
                }
                catch { Functions.Alert("Gửi câu hỏi thất bại!", Request.Url.ToString()); }
            }
        }
    }
}
